#include "kernel/ilog.h"
#include "mutexwin.h"
#include "kernel/debug.h"

namespace rengine3d {

	CMutexWin::CMutexWin() {
		m_hMutex = CreateMutex(nullptr, false, nullptr);
	}

	CMutexWin::~CMutexWin() {
		if (m_hMutex)
			CloseHandle(m_hMutex);
	}

	bool CMutexWin::Lock() {
		return (m_hMutex && WaitForSingleObject(m_hMutex, INFINITE) == WAIT_OBJECT_0);
	}

	bool CMutexWin::UnLock() {
		return (m_hMutex && ReleaseMutex(m_hMutex));
	}

}
